﻿Imports System.Windows.Forms
Imports System.Drawing.Printing

Public Class Imprimantes

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        My.Settings.printer = imprimante.SelectedItem
        My.Settings.printerType = type.Text
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub Imprimante_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       Dim printers As PrinterSettings.StringCollection
        printers = PrinterSettings.InstalledPrinters()
        For x As Integer = 0 To printers.Count - 1
            imprimante.Items.Add(printers(x))
            If My.Settings.printer = printers(x) Then
                imprimante.SelectedIndex = x
            End If
        Next
        type.Text = My.Settings.printerType

    End Sub

End Class
